package com.qidianit.mes.pro.controller;

import com.github.pagehelper.PageInfo;
import com.qidianit.mes.pojo.Result;
import com.qidianit.mes.pojo.pro.ProcessStep;
import com.qidianit.mes.pro.service.ProcessStepService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description:
 * @Author: YanJiRan
 * @Date: 2025/9/17 - 下午5:18
 */
@RestController
@RequestMapping("/processStep")
public class ProcessStepController {
    @Autowired
    private ProcessStepService processStepService;

    @GetMapping("/page")
    public Result<PageInfo<ProcessStep>> list(ProcessStep processStep, @RequestParam(defaultValue = "1") int pageNum, @RequestParam(defaultValue = "10") int size){
        return processStepService.selectList(processStep,pageNum,size);
    }

    @GetMapping("/get/{id}")
    public Result<ProcessStep> getByProcessStepId(@PathVariable("id") Long id){
        return processStepService.selectById(id);
    }

    @PostMapping("/add")
    public Result<ProcessStep> saveProcessStep(@RequestBody ProcessStep processStep){
        return processStepService.saveProcessStep(processStep);
    }

    @PutMapping("/update")
    public Result<ProcessStep> updateById(@RequestBody ProcessStep processStep){
        return processStepService.updateById(processStep);
    }

    @DeleteMapping("/delete/{id}")
    public Result<ProcessStep> deleteById(@PathVariable("id") Long id){
        return processStepService.deleteById(id);
    }
}
